package cn.edu.cdu.taobao.util;

import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import cn.edu.cdu.taobao.net.Brower;

public class TaobaoShop {
	public static void main(String[] args) {
		String urlTaboBao="http://xiaoxiangbag.taobao.com/search.htm";
	    String urlTmall="http://rowa.tmall.com/search.htm";
		get(urlTmall);
	}
	
	public static void get(String url) {
		Document document=Brower.getByJsoup(url);
		
		Element element=document.getElementById("J_ShopSearchResult");
		Elements shopPages=document.getElementsByClass("page-info");
		getPageNo(shopPages.get(0).text());
		
		System.out.println(shopPages.get(0).text());
		
		Elements elements=  element.getElementsByClass("shop-list");
		Element grid=elements.get(0);
		
		Elements listItemElements=grid.getElementsByClass("item");
		System.out.println(listItemElements.get(0));

		
		
		
		
		System.out.println(elements.size());
		System.out.println(listItemElements.size());
	}

	private static void getPageNo(String text) {
		// TODO Auto-generated method stub
		String [] pageNoStrings=text.split("/");
		if (pageNoStrings.length>0) {
			System.out.println(pageNoStrings[1]);
		}
	}
}
